package com.heima.ssm.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Penguin
 * @create Date 2021/4/21  Time 19:20
 */
public class DateUtils {

    //日期转换成字符串
    public static String date2String(Date date,String pattern){
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        String newDate = sdf.format(date);
        return newDate;
    }


    //字符串转换成日期
    public static Date string2Date(String str ,String pattern) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date parse = sdf.parse(str);
        return parse;
    }


}
